<?xml version='1.0' encoding='UTF-8' ?>
<!DOCTYPE composition PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<ui:composition xmlns:ui="http://java.sun.com/jsf/facelets"
                template="./template.xhtml"
                xmlns:h="http://java.sun.com/jsf/html"
                xmlns:c="http://java.sun.com/jsp/jstl/core"
                xmlns:f="http://java.sun.com/jsf/core"
                xmlns="http://www.w3.org/1999/xhtml">

    <ui:define name="top">
        Manage Cart
    </ui:define>

    <ui:define name="left">
    </ui:define>


    <ui:define name="body">
        <h:form id="manageCartForm">
            <c:choose>
                <c:when test="#{cartCTRL.order.orderLinksList.rowCount > 0}">
                    <h:dataTable width="100%" value="#{cartCTRL.order.orderLinksList}" var="item" border="0" cellpadding="2" cellspacing="0" rowClasses="jsfcrud_odd_row,jsfcrud_even_row" rules="all" style="border:solid 1px; font-size: 9px;">
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Name"/>
                            </f:facet>
                            <h:outputText value="#{item.item.name}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Description"/>
                            </f:facet>
                            <h:outputText value="#{item.item.descrip}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Quantity"/>
                            </f:facet>
                            <h:inputText size="3" value="#{item.q}">
                                <f:convertNumber type="number"/>
                                <f:validateLongRange minimum="0"/>
                            </h:inputText>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Price"/>
                            </f:facet>
                            <h:outputText value="\$#{item.item.price}"/>
                        </h:column>
                        <h:column>
                            <f:facet name="header">
                                <h:outputText value="Delete"/>
                            </f:facet>
                            <h:selectBooleanCheckbox value="#{item.selected}"/>
                        </h:column>
                    </h:dataTable>
                    <h:outputText value="Total: #{cartCTRL.order.amount}"/>
                    <br/>
                    <h:commandButton action="#{cartCTRL.updateCart}" value="Submit Changes"/>
                    <h:button value="CheckOut" outcome="CheckOut"/>
                </c:when>
                <c:otherwise>
                    Your cart is empty!
                </c:otherwise>
            </c:choose>
            
            
            
        </h:form>
    </ui:define>

</ui:composition>
